<!--
 -- ViewAnalysisLib.php
 -- v0.01
 -- 3/7/2011
 --
 -- This PHP file contains dtabase functions which is intended for the lookup
 -- and storage of analysis values.
 -->
<?php
	/**
	 * This function lets the caller display all of the current analysis that
	 * is in the 'analysis_request' database table.
	 * @param unknown_type $database
	 * @param unknown_type $host
	 * @param unknown_type $login
	 * @param unknown_type $loginpassword
	 */
	function DisplayAllAnalysis($database, $host, $login, $loginpassword){
		//cREATE CONNECTION.
		$connect = mysql_connect("localhost", "createanalysis", 
				"createanalysis");
		if (!$connect) {
			die('Could not connect: ' . mysql_error());
		}
		mysql_select_db($database, $connect);
		
		//Execute query.
		$result = mysql_query("SELECT * FROM analysis_request");
		$listall = NULL;
		$inti = 0;
		
		//Display all results row by row to the caller.
		while($row = mysql_fetch_array($result) ){
			echo ' <tr><th>'. $row["CASL_NUM"].'</th>
					<th>'.$row["NAME"].'</th><th>'.$row["DATE_CREATED"].'
					</th></tr> ';
		}
		
		//Close connection.
		mysql_close($connect);
	}
	
	/**
	 * The function searches for rows in the 'analysis_request' database
	 * table where the CASL number matches to the parameter.
	 * @param unknown_type $casl
	 * @param unknown_type $database
	 * @param unknown_type $host
	 * @param unknown_type $login
	 * @param unknown_type $loginpassword
	 */
	function SearchCASL($casl, $database, $host, $login, $loginpassword){
		//Create connection and select database.
		$connect = mysql_connect("localhost", "createanalysis",
				"createanalysis");
		if (!$connect) {
			die('Could not connect: ' . mysql_error());
		}
		mysql_select_db($database, $connect);
		
		//Execute query.
		$searchquery = "SELECT * FROM analysis_request where casl_num='$casl'";
		$result = mysql_query($searchquery);
		$listall= NULL;
		$inti=0;
		
		//Display all results row by row to the caller.
		while($row = mysql_fetch_array($result) ){
			echo ' <tr><th>'. $row["CASL_NUM"].'</th><th>'.$row["NAME"].
					'</th><th>'.$row["DATE_CREATED"].'</th></tr> ';
		}
		
		//Close connection.
		mysql_close($connect);	
	}
		
	/**
	 * The function searches for rows in the 'analysis_request' database
	 * table where the CASL date matches to the parameter.
	 * @param unknown_type $casl
	 * @param unknown_type $database
	 * @param unknown_type $host
	 * @param unknown_type $login
	 * @param unknown_type $loginpassword
	 */
	function SearchDate($casl, $database, $host, $login, $loginpassword){
		//Create connection and select database.
		$connect = mysql_connect("localhost","createanalysis","createanalysis");
		if (!$connect) {
			die('Could not connect: ' . mysql_error());
		}
		mysql_select_db($database, $connect);
		
		//Execute query.
		$searchquery = "SELECT * FROM analysis_request where casl_num='$casl'";
		$result = mysql_query($searchquery);
		$listall= NULL;
		$inti=0;
		
		//Display all results row by row to the caller.
		while($row = mysql_fetch_array($result) ){
			echo ' <tr><th>'. $row["CASL_NUM"].'</th><th>'.$row["NAME"].
					'</th><th>'.$row["DATE_CREATED"].'</th></tr> ';
		}

		//Close connection.
		mysql_close($connect);	
	}
?>